/**
* Created by alan on 2018/3/10.
*/
<template>
  <section class="orderBox">
    <div class="divid-line"></div>
    <el-row>
      <div class="containers">
        <div class="asides">
          <div class="one-title">活动信息</div>
          <table border='.1px' width="100%" style="table-layout:fixed;">
            <tr>
              <td>活动专题</td>
              <td>{{searchForm.activitySubject}}</td>
            </tr>
            <tr>
              <td>活动主题</td>
              <td>{{searchForm.title}}</td>
            </tr>
            <tr>
              <td>开始时间</td>
              <td>{{getdate(searchForm.startTime)}}</td>
            </tr>
            <tr>
              <td>结束时间</td>
              <td>{{getdate(searchForm.endTime)}}</td>
            </tr>
            <tr>
              <td>参数人数</td>
              <td>{{searchForm.persionCount}}</td>
            </tr>
            <tr>
              <td>实到人数</td>
              <td>{{searchForm.attendanceCount}}</td>
            </tr>
            <tr>
              <td>活动要求</td>
              <td>{{searchForm.required}}</td>
            </tr>
          </table>
        </div>
      </div>
    </el-row>
    <div class="divid-line"></div>
    <el-row>
      <div class="one-title">活动内容</div>
      <div id="app">
        <mavon-editor v-model="searchForm.content" default_open='preview' :ishljs="true"
                      placeholder="填写活动内容" :editable="false" :toolbarsFlag="false" :subfield="true"></mavon-editor>
      </div>
    </el-row>
    <div class="divid-line"></div>
    <el-row v-if="type == 3">
      <div class="one-title">图片资料</div>
      <div class="cardImg" v-for="(item,index) in picList">
        <ml-photo-box ref='photoBox'></ml-photo-box>
        <img :src="item.url" @click.stop="attachmentUrl(picList[0])"><br>{{item.name}}
      </div>
    </el-row>
    <div class="divid-line"></div>
    <el-row v-if="type == 3">
      <div class="one-title">文件资料</div>
      <el-table :data="fileList" width="100%"  @row-click="rowClick" size="large">
        <el-table-column type="index" label="序号" width="200" ></el-table-column>
        <el-table-column prop="name"  label="文件名称"></el-table-column>
        <el-table-column label="操作" prop="remark">
          <template scope="scope">
            <el-button size="small" @click="downLoadFile(scope.row)" type="success">下载</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <div class="divid-line"></div>
    <el-row>
      <div class="one-title">用户评分</div>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column
          prop="realName"
          label="姓名">
        </el-table-column>
        <el-table-column
          prop="userScore"
          label="用户评分">
        </el-table-column>
        <el-table-column
            prop="remark"
            label="用户自评">
        </el-table-column>
        <el-table-column
          prop="organizerScore"
          label="组织评分">
        </el-table-column>
        <el-table-column label="操作">
          <template scope="scope">
            <el-button size="small" type="success" @click="edit(scope.row)" :disabled="updateButton">修改评分</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>

    <div class="divid-line"></div>

    <el-dialog title="修改评分" v-model="addDialogVisible" :close-on-click-modal="false" size="tiny">
      <el-form :model="addForm" label-position="left" label-width="80px">
        <el-form-item label="组织评分" prop="orginzerScore">
          <el-input v-model="addForm.orginzerScore" auto-complete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addFormSubmit">提 交</el-button>
      </div>
    </el-dialog>
  </section>
</template>
<script>
  import enums from '../../common/Enum'
  import DataUtil from '../../common/dataUtil'
  import Config from '../../common/config'
  import ElRow from "element-ui/packages/row/src/row";
  export default {
    components: {ElRow},
    data () {
      return {
        showDetail: true,
        addDialogVisible: false,
        subfield: true,
        code_style: 'solarized-dark',
        external_link: {
          hljs_css: function(css) {
            // 这是你的代码高亮配色文件路径
            return '/highlight.js-9.12.0/styles/' + css + '.min.css';
          },
          katex_css: false, // `false`表示禁用自动加载，它也可以是个函数，如果它是个函数，那么这个函数应该返回一个可访问的`katex`的css路径字符串
          // 我们没有设置`katex_js`, `hljs_js`, `hljs_lang`, `markdown_css`， `mavon-editor`会认为它的值为`true`，它会默认使用`cdnjs`相关外链加载
        },
        searchForm:{
          activitySubject: '',
          title:'',
          persionCount:0,
          attendanceCount:0,
          required:'',
          content:'',
          startTime:'',
          endTime:'',
          subject:'',
        },
        fileList:[],
        updateButton: false,

        tableData: [],
        picList:[],
        activitySubject: [],
        pageIndex: 1,
        pageSize: 10,
        addForm: {
          orginzerScore: '',
          id:'',
        },
        type: '',
      }
    },
    methods: {
      attachmentUrl(item){
        if(item.url){
          let _photoList = [
            item.url
          ];
          this.$refs.photoBox.show(_photoList)
        }
      },
      downLoadFile(row) {
        window.open('http://localhost:8089/api/check/getDataSource?id=' + row.id)
//        this.$http.get("http://localhost:8089/check/getDataSource",{id:row.id});
      },
      getdate(dates) {
        if(!dates){
          return '';
        }
        var myDate = new Date(dates);
        var offset = -7*60*60000;
        offset = myDate.getTimezoneOffset()*60000;
        var myDates = new Date(dates+offset+7*3600000);
        // myDate.setUTCHours(10);
        // return myDate.toLocaleString(); //获取日期与时间
        let minute=myDates.getMinutes();
        if(minute<10){
          minute="0"+minute;
        }
        let seconds=myDates.getSeconds()
        if(seconds<10){
          seconds="0"+seconds;
        }
        return myDates.getFullYear()+"-"+(myDates.getMonth()+1)+"-"+myDates.getDate()+" "+myDates.getHours()+":"+minute+":"+seconds
      },
      getdate(dates) {
        if(!dates){
          return '';
        }
        var myDate = new Date(dates);
        let minute=myDate.getMinutes();
        if(minute<10){
          minute="0"+minute;
        }
        let seconds=myDate.getSeconds()
        if(seconds<10){
          seconds="0"+seconds;
        }
        return myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate()+" "+myDate.getHours()+":"+minute+":"+seconds
      },
      getStatus(type) {
        let re = '';
        this.status.forEach(obj => {
          if (obj.code == type) {
            re = obj.name;
            return
          }
        });
        return re
      },
      search() {
        this.bindGrid()
      },
      rowClick(row){
        window.open('#/OrderDetails?seen=true&userUuid='+row.userUuid+
          '&uuid='+row.uuid);
      },
      bindGrid() {

          if (DataUtil.userRole() == 1) {
              this.updateButton = true;
          }
          this.type = this.$route.query['type'] ||'';
        let _data = {
//          id: DataUtil.uuid,
          id :this.$route.query['id']||'',
          pageNo:this.pageIndex,
          pageSize:this.pageSize
        };
        if (_data.id == '' || _data.id == 0) {
          return ;
        }
        this.$http.post('activity/listActivity', _data).then(response => {
          if (1 == response.body.code) {
            this.searchForm = response.body.data.list[0];
          } else {
            this.$message.error(body.message);
          }
        }).catch((e) =>{
          this.gridLoading = false;
        })

        this.$http.post('activityDetail/listActivityDetail', _data).then(response => {
          if (1 == response.body.code) {
            this.tableData = response.body.data;
          } else {
            this.$message.error(body.message);
          }
        }).catch((e) =>{
          this.gridLoading = false;
        })

      },
      getActivitySubject() {

        this.$http.post('activity/listActivitySubject',{}).then(response => {
          if (response.body.code == 1) {
            this.activitySubject = response.body.data;
          }
        });
      },
      edit(scope) {
        this.addForm.orginzerScore = scope.organizerScore;
        this.addDialogVisible = true;
        this.addForm.id = scope.id;
      },
      addFormSubmit() {

        this.addDialogVisible = false;
          let _data = {
              id: this.addForm.id,
            organizerScore:  this.addForm.orginzerScore
          }
        this.$http.post('activityDetail/updateActivityDetail',_data).then(response => {
          if (response.body.code == 1) {
              _data.id = this.$route.query['id']||'';
            this.$http.post('activityDetail/listActivityDetail', _data).then(response => {
              if (1 == response.body.code) {
                this.tableData = response.body.data;
              } else {
                this.$message.error(body.message);
              }
            }).catch((e) =>{
              this.gridLoading = false;
            })
          }
        });
      },
      getAllCheckData() {
        this.$http.post('check/getAllOrginzeData', {userId: DataUtil.id(), type: 1, fileType: 1}).then(response => {
          if (response.body.code == 1) {
            this.picList = response.body.data;
          }
        });
        this.$http.post('check/getAllOrginzeData', {userId: DataUtil.id(), type: 1, fileType: 2}).then(response => {
          if (response.body.code == 1) {
            this.fileList = response.body.data;
          }
        });
      },
    },
    mounted: function () {
      this.bindGrid();
      this.getAllCheckData();
    }
  }
</script>

<style>
  .v-note-edit {
    display: none;
  }
  .v-note-wrapper .v-note-panel .v-note-show {
    flex: 0 0 100% !important;
  }
  .reviewTable {
    width: 80%;
    border-spacing: 0;
    border: 1px solid gray;
    margin: 20px auto;
  }
  .reviewTable td {
    text-align: center;
    border: 1px solid gray;
    height: 40px;
    line-height: 40px;

    width: 50%;
    word-wrap:break-word;
  }
  .videos {
    width: 80%;
    margin: 20px auto;
  }
  /*侧边框布局*/
  .containers {
    width: 100%;
    /*height: 400px;*/
    display: flex;

  }
  .containers .asides {
    flex: 6;

  }
  .containers .mains {
    flex: 4;
    margin-left: 40px;
  }
  .other_remark {
    width: 100%;
  }
  .mains .smallRemark {
    width: 100%;
  }
  .cardImg {
    width: 40%;
    height: 300px;
    overflow: hidden;
    margin: 1.5%;
    float: left;
    text-align: center;
  }
  .asides table {
    border-spacing: 0;
    border: 1px solid #A9A9A9 ;
    border-radius: 2px;
  }
  .asides table td {
    border: .5px solid #efefef;
    word-wrap:break-word;
    line-height: 20px;
    padding: 5px;
  }
  table td img {
    width: 100%;
  }
  .aside_title {
    font-weight: 400;
    line-height: 40px;
    font-size: 16px;
  }
  .question_radio {
    padding-bottom: 30px;
    margin: 5px 10px;
  }
  .question_radio .radio_box {
    /*margin-bottom: -30px;*/
    line-height: 20px;
    float: right;
  }
  .addreBook {
    text-align: center;
    width: 40px;
  }
  /* 标题 */
  .main-title{
    font-size: 22px;
    margin-top: -15px;
    margin-bottom: 15px;
  }
  .one-title{
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 7px;
  }
  .two-title{
    font-size: 13px;
    color: #888;
    margin: 10px 0
  }
  .subtitle{
    font-size: 13px;
    color: #888;
  }
  .orderBox .el-row {
    margin: 15px 30px;
  }
  .orderBox .el-col span{
    margin-right: 10px;
  }
  .orderBox .el-button span,.orderBox .el-tag span{
    margin-right: 0;
  }
  .orderBox .box-card .el-button{
    margin-right: 5px;
  }
  .orderBox .grid-content {
    line-height: 28px;
  }

  .divid-line{
    height: 10px;
    background: #f1f2f7;
  }
  /*借款信息*/
  .loanDetail{
    margin: 0 30px 15px;
    width: 94%;
    max-height:250px;
  }
  /*依图识别*/
  .yituInfo{
    display: block;
    text-align: center;
    margin-top: 10px;
  }
  /*征信*/
  .orderBox .box-card{
    height: 225px;
  }
  .JXLBox{
    border: 1px solid #ccc;
    padding: 10px
  }
  .JXLBox div{
    padding: 5px;
  }

  .orderBox .el-table .info-row {
    background: #e2f0e4;
  }

  .orderBox .el-table .red-row{
    background: #F33;
  }
  .redInfo{
    color: #F33;
  }

  .line-height .el-col{
    margin-bottom: 10px;
  }
  .faceCheck {
    margin: 0 auto;
    overflow: hidden;
  }
  .faceCheck .faceImg{
    width: 45%;
    height: 350px;
    overflow: hidden;
    margin: 1.5%;
    float: left;
    text-align: center;
  }
  .faceCheck .faceImg img {
    margin: 0 auto;
    display: block;
    width: 90%;
    height: 90%;
    /*    border: .5px solid #F1F2F7;
    border-radius: 5px;*/
  }
  .faceImgTop {
    width: 45%;
    height: 250px;
    /*overflow: hidden;*/
    margin: 1.5%;
    float: left;
    text-align: center;
  }
  .faceImgTop img{
    margin: 0 auto;
    height: 200px;
    display: block;
    max-height: 100%;
    max-width: 100%;
    min-width: 65%;
    min-height: 65%;
    border: .5px solid #F1F2F7;
    border-radius: 5px;
  }
  .faceImgBottom {
    width: 90%;
    height: 350px;
    overflow: hidden;
    margin: 2.5%;
    float: left;
    text-align: center;

  }
  .faceImgBottom img{
    margin: 0 auto;
    display: block;
    height: 300px;
    min-width: 80%;
    min-height: 80%;
    border: .5px solid #F1F2F7;
    border-radius: 5px;
  }

  #btnForm{
    width: 90%;
    margin: 0 auto
  }
  #studentsInf td img{
    max-width: 300px;
    max-height: 200px;
  }
  .lastTitle {
    margin-right: 40px;
    float: left;
    font-weight: 400;
    line-height: 40px;
    font-size: 16px;
  }
  .reviewTable {
    width: 60%;
    margin: 0 auto;
  }
  table td img {
    width: 100%;
  }
  .faceImgTop .handleImg {
    width: 40%;
    transform: rotate(-90deg);
    -webkit-transform: rotate(-90deg);
  }
  .vadio {
    float: left;
    margin-left:60px;
    transform: rotate(-180deg);
    -webkit-transform: rotate(-180deg);
  }
  .vadios {
    float: left;
    margin-right:60px;
  }
</style>
